import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '余额',
    align: "center",
    dataIndex: 'balance'
  },
  {
    title: '用户',
    align: "center",
    dataIndex: 'userId_dictText'
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'start_dictText'
  },
  {
    title: '账号',
    align: "center",
    dataIndex: 'account'
  },
  {
    title: '姓名',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '手机号',
    align: "center",
    dataIndex: 'phone'
  },
  {
    title: '类型',
    align: "center",
    dataIndex: 'type'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "用户",
    field: 'userId',
    component: 'JSearchSelect',
    componentProps: {
      dict: "cu_user_details,user_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "状态",
    field: 'start',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "transaction_status"
    },
    //colProps: {span: 6},
  },
  {
    label: "账号",
    field: 'account',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "姓名",
    field: 'name',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "手机号",
    field: 'phone',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "类型",
    field: 'type',
    component: 'Input',
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '余额',
    field: 'balance',
    component: 'InputNumber',
  },
  {
    label: '用户',
    field: 'userId',
    component: 'JSearchSelect',
    componentProps: {
      dict: "cu_user_details,user_name,id"
    },
  },
  {
    label: '状态',
    field: 'start',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "transaction_status"
    },
  },
  {
    label: '账号',
    field: 'account',
    component: 'Input',
  },
  {
    label: '姓名',
    field: 'name',
    component: 'Input',
  },
  {
    label: '手机号',
    field: 'phone',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: false },
        { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!' },
      ];
    },
  },
  {
    label: '类型',
    field: 'type',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  balance: { title: '余额', order: 0, view: 'number', type: 'number', },
  userId: { title: '用户', order: 1, view: 'sel_search', type: 'string', dictTable: "cu_user_details", dictCode: 'id', dictText: 'user_name', },
  start: { title: '状态', order: 2, view: 'list', type: 'string', dictCode: 'transaction_status', },
  account: { title: '账号', order: 3, view: 'text', type: 'string', },
  name: { title: '姓名', order: 4, view: 'text', type: 'string', },
  phone: { title: '手机号', order: 5, view: 'text', type: 'string', },
  type: { title: '类型', order: 6, view: 'text', type: 'string', },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}